package com.swagger.gitee.swagger;



import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
 
@Configuration 
public class Swagger2 {
	
	@Bean
	public Docket createRestApi() {
		//basePackage基础包要写对，否则页面会有一个错误存在
		return new Docket(DocumentationType.SWAGGER_12)
				.apiInfo(apiInfo())
				.select()
				.apis(RequestHandlerSelectors.basePackage("com.swagger.gitee.swagger"))
				.paths(PathSelectors.any())
				.build();
	}
	
	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.title("标题：swagger 和 springboot的集成")
				.description("描述：关于swagger解析多层")
				.termsOfServiceUrl("http://localhost:8080/swagger-ui.html")
				.version("2.7.0")
				.build();
	}
 
}
